<?php
/**
 * Created by PhpStorm.
 * User: dream
 * Date: 2017/8/16
 * Time: 14:17
 */

/**
 * Class BootstrapPagination
 *
 * Bootstrap  分页样式  只需要传入 base_url  count_result  per_page即可
 */
class Bootstrap
{

    private $ci =  null;

    public function __construct()
    {
        $this->ci = &get_instance();
    }

    public function getLinks($base_url,$count_result,$per_page,$show_count=true)
    {
        $this->ci->load->library("pagination");

        //是否显示记录条数
        if($show_count)
            $count_result_show = "<li><a>共有".$count_result."条记录</a></li></ul>";
        else
            $count_result_show = "</ul>";
        //分页配置
        $page_config = [
            "base_url"=>$base_url,
            "total_rows"=>$count_result,
            "full_tag_open"=>" <ul class='pagination  pagination-sm'>",
            "full_tag_close"=>$count_result_show,
            "per_page"=>$per_page,
            "first_link"=>"首页",
            "first_tag_open"=>"<li>",
            "first_tag_close"=>"</li>",
            "last_tag_open"=>"<li>",
            "last_tag_close"=>"</li>",
            "last_link"=>"尾页",
            "prev_link"=>"«",
            "next_link"=>"»",
            "prev_tag_open"=>"<li>",
            "prev_tag_close"=>"</li>",
            "next_tag_open"=>"<li>",
            "next_tag_close"=>"</li>",
            "cur_tag_open"=>"<li class='active'><a>",
            "cur_tag_close"=>"</a></li>",
            "num_tag_open"=>"<li>",
            "num_tag_close"=>"</li>"
        ];
        $this->ci->pagination->initialize($page_config);

        $link_str = $this->ci->pagination->create_links();

        return $link_str;
    }

}